package com.zzedu.framework.manager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.stereotype.Component;

import java.util.TimerTask;

/**
 * 异步任务管理器
 *
 * @author liuhulu
 */
@Component
public class AsyncManager {
    /**
     * 操作延迟10毫秒
     */
    private final int OPERATE_DELAY_TIME = 10;

    /**
     * 异步操作任务调度线程池
     */

    private static AsyncTaskExecutor executor;

    @Autowired
    public void setExecutor(AsyncTaskExecutor executor) {
        AsyncManager.executor = executor;
    }

    /**
     * 执行任务
     *
     * @param task 任务
     */
    public static void execute(TimerTask task) {
        executor.execute(task);
    }


}
